<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    var userlist = [
      [1, "A根节点", 0],
      [2, "A二级节点1", 1],
      [3, "A二级节点2", 1],
      [4, "A二级节点3", 1],
      [5, "A三级节点1", 2],
      [6, "A三级节点2", 2],
      [7, "A三级节点3", 2],
      [8, "A三级节点4", 3],
      [9, "A三级节点5", 3],
      [10, "A三级节点6", 3],
      [11, "A三级节点7", 4],
      [12, "A三级节点8", 4],
      [13, "A三级节点9", 4],
      [14, "B根节点", 0],
      [15, "B二级节点", 14],
    ];

    let root = (id) => {
      if (userlist[id - 1][2] == 0) {
        return userlist[id - 1]
      } else {
        // userlist.forEach(item => {
        //   if (item[0] == id) {
        //     return root(item[2])
        //   }
        // })
        // return '1'
        return root(userlist[id-1][2])
      }
    }
    console.log(root(9))
  </script>
</body>

</html>